package com.yc.home.cloudother.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yc.entity.Classs;
import com.yc.entity.Createclass;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author lzk
 * @since 2024-10-05
 */
public interface CreateclassMapper extends BaseMapper<Createclass> {

    @Results(
            id = "rm1", value = {
                    @Result(column = "id", property = "id", id = true),
            @Result(column = "id", property = "classobj", many = @Many(
                    select = "selectClassByIdAndStatus"
            ))
    }
    )
    @Select("select * from createclass where id = #{id}")
    Createclass byIdClass(String id);

    @Select("select * from classs where cid = #{cid} and status in (1, 2)")
    List<Classs> selectClassByIdAndStatus(@Param("cid") String cid);


    @Results(
            id = "rm2", value = {
            @Result(column = "id", property = "id", id = true),
            @Result(column = "id", property = "classobj", many = @Many(
                    select = "selectClassByIdAndStatus1"
            ))
    }
    )
    @Select("select * from createclass where id = #{id}")
    Createclass byIdAudit(String id);

    @Select("select * from classs where cid = #{cid} and status in (-1, 0) order by status desc")
    List<Classs> selectClassByIdAndStatus1(@Param("cid") String cid);
}
